package org.zbus.proxy.tc;


import java.util.HashMap;
import java.util.Map;

import org.zbus.broker.Broker;
import org.zbus.broker.BrokerConfig;
import org.zbus.broker.SingleBroker;
import org.zbus.net.http.Message.MessageInvoker;
import org.zbus.rpc.RpcFactory;
import org.zbus.rpc.mq.MqInvoker;

public class TcExample {

	public static void main(String[] args) throws Exception {
		//1) 动态代理TcService
		BrokerConfig config = new BrokerConfig();
		config.setServerAddress("127.0.0.1:15555");
		Broker broker = new SingleBroker(config); 
		 
		MessageInvoker invoker = new MqInvoker(broker, "ETC-172.24.181.70"); 
		RpcFactory factory = new RpcFactory(invoker); 
		TcService tc = factory.getService(TcService.class); 
		
		
		
		//2)像本地方法一样调用远程的TC服务
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("org_code", "1100");
		params.put("org_type", "2");
		
		Object res = tc.callMap(300, 750, 4, params);
		System.out.println(res);
		
		res = tc.callString(300, 750, 4, "org_code=1100&org_type=2");
		System.out.println(res);
		
		
		broker.close();
	}
}
